﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations.Schema;

namespace S4Store.Domain.NetMarketingKpi
{
    public class NetMarketingMonthData
    {
        public int Id { get; set; }

        /// <summary>
        /// 是否确认
        /// </summary>
        public bool IsConfirmed { get; set; }
        /// <summary>
        /// 月
        /// </summary>
        public DateTime Month { get; set; }

        /// <summary>
        /// 店
        /// </summary>
        public int StoreId { get; set; }

        /// <summary>
        /// 店
        /// </summary>
        public virtual Store Store { get; set; }

        /// <summary>
        /// 上月线上客户转化率
        /// </summary>
        public decimal SYXSKHZHLV { get; set; }

        /// <summary>
        /// 电销目标
        /// </summary>
        public int DXMB { get; set; }

        /// <summary>
        /// 电销平均成交率
        /// </summary>
        public decimal DXPJCJLV { get; set; }


        /// <summary>
        /// 网络营销资金月度预算
        /// </summary>
        public decimal WLYXZJYDYS { get; set; }

        /// <summary>
        /// 网络资金实际投入总额
        /// </summary>
        public decimal WLZJSJTRE { get; set; }


        /// <summary>
        /// 上月微信被关注数
        /// </summary>
        public int SYWXBGZD { get; set; }
        /// <summary>
        /// 企业微信月度成本
        /// </summary>
        public decimal QYWXYDCB { get; set; }

        /// <summary>
        /// 企业微信计划发贴数
        /// </summary>
        public int QYWXJHFTS { get; set; }

        /// <summary>
        /// 企业微信实际发贴数
        /// </summary>
        public int QYWXSJFTS { get; set; }

        /// <summary>
        /// 本月企业微信被关注数
        /// </summary>
        public int BYQYWXBGZD { get; set; }



        /// <summary>
        /// 上月微博被关注数
        /// </summary>
        public int SYWBBGZD { get; set; }

        /// <summary>
        /// 企业微博月度成本
        /// </summary>
        public decimal QYWBYDCB { get; set; }

        /// <summary>
        /// 企业微博计划发贴数
        /// </summary>
        public int QYWBJHFTS { get; set; }

        /// <summary>
        /// 企业微博实际发贴数
        /// </summary>
        public int QYWBSJFTS { get; set; }

        /// <summary>
        /// 企业微博被关注数
        /// </summary>
        public int QYWBBGZD { get; set; }




        /// <summary>
        /// 网站1月度费用
        /// </summary>
        public decimal WZ1YDFY { get; set; }

        /// <summary>
        /// 网站1计划发贴数
        /// </summary>
        public int WZ1JHFTS { get; set; }

        /// <summary>
        /// 网站1实际发贴数
        /// </summary>
        public int WZ1SJFTS { get; set; }

        /// <summary>
        /// 网站1获取信息数
        /// </summary>
        public int WZ1HQXXS { get; set; }

        /// <summary>
        /// 网站1来电数
        /// </summary>
        public int WZ1LDS { get; set; }



        /// <summary>
        /// 网站2月度费用
        /// </summary>
        public decimal WZ2YDFY { get; set; }

        /// <summary>
        /// 网站2计划发贴数
        /// </summary>
        public int WZ2JHFTS { get; set; }

        /// <summary>
        /// 网站2实际发贴数
        /// </summary>
        public int WZ2SJFTS { get; set; }

        /// <summary>
        /// 网站2获取信息数
        /// </summary>
        public int WZ2HQXXS { get; set; }

        /// <summary>
        /// 网站2来电数
        /// </summary>
        public int WZ2LDS { get; set; }



        /// <summary>
        /// 网站3月度费用
        /// </summary>
        public decimal WZ3YDFY { get; set; }

        /// <summary>
        /// 网站3计划发贴数
        /// </summary>
        public int WZ3JHFTS { get; set; }

        /// <summary>
        /// 网站3实际发贴数
        /// </summary>
        public int WZ3SJFTS { get; set; }

        /// <summary>
        /// 网站3获取信息数
        /// </summary>
        public int WZ3HQXXS { get; set; }

        /// <summary>
        /// 网站3来电数
        /// </summary>
        public int WZ3LDS { get; set; }

        /// <summary>
        /// 网站资金投入率
        /// </summary>
        [NotMapped]
        public decimal WZZJTRLV
        {
            get
            {
                if (WLYXZJYDYS == 0) return 0;
                return WLZJSJTRE * 100 / WLYXZJYDYS;
            }
        }
        /// <summary>
        /// 网络获取资源总数
        /// </summary>
        [NotMapped]
        public int WLHQZYZS
        {
            get
            {
                return WZ1HQXXS + WZ1LDS + WZ2HQXXS + WZ2LDS;
            }
        }
        /// <summary>
        /// 来店量目标
        /// </summary>
        [NotMapped]
        public int LDLMB
        {
            get
            {
                if (DXPJCJLV == 0) return 0;
                return (int)(DXMB * 100 / DXPJCJLV);
            }
        }
        /// <summary>
        /// 获取信息量目标
        /// </summary>
        [NotMapped]
        public int HQXXLMB
        {
            get
            {
                if (SYXSKHZHLV == 0) return 0;
                return (int)(LDLMB * 100 / SYXSKHZHLV);
            }
        }
        /// <summary>
        /// 网络集客目标
        /// </summary>
        [NotMapped]
        public int WLJKMB
        {
            get { return HQXXLMB; }
        }

        /// <summary>
        /// 网络集客进度
        /// </summary>
        [NotMapped]
        public decimal WLJKJD
        {
            get
            {
                if (WLJKMB == 0) return 0;
                return WLHQZYZS * 100 / WLJKMB;
            }
        }
        /// <summary>
        /// 网站1费用占比
        /// </summary>
        [NotMapped]
        public decimal WZ1FYZB
        {
            get
            {
                if (WLZJSJTRE == 0) return 0;
                return WZ1YDFY * 100 / WLZJSJTRE;
            }
        }
        /// <summary>
        /// 网站2费用占比
        /// </summary>
        [NotMapped]
        public decimal WZ2FYZB
        {
            get
            {
                if (WLZJSJTRE == 0) return 0;
                return WZ2YDFY * 100 / WLZJSJTRE;
            }
        }
        /// <summary>
        /// 网站1资源总数
        /// </summary>
        [NotMapped]
        public int WZ1ZYZS
        {
            get
            {
                return WZ1HQXXS + WZ1LDS;
            }
        } 
        /// <summary>
        /// 网站2资源总数
        /// </summary>
        [NotMapped]
        public int WZ2ZYZS
        {
            get
            {
                return WZ2HQXXS + WZ2LDS;
            }
        }
        /// <summary>
        /// 网站1资源占比
        /// </summary>
        [NotMapped]
        public decimal WZ1ZYZB
        {
            get
            {
                if (WLHQZYZS == 0) return 0;
                return WZ1ZYZS * 100 / WLHQZYZS;
            }
        }
        /// <summary>
        /// 网站2资源占比
        /// </summary>
        [NotMapped]
        public decimal WZ2ZYZB
        {
            get
            {
                if (WLHQZYZS == 0) return 0;
                return WZ2ZYZS * 100 / WLHQZYZS;
            }
        }

        /// <summary>
        /// 网站1单次资源成本
        /// </summary>
        [NotMapped]
        public decimal WZ1DCZYCB
        {
            get
            {
                if (WZ1YDFY == 0) return 0;
                return WZ1ZYZS / WZ1YDFY;
            }
        }
        /// <summary>
        /// 网站2单次资源成本
        /// </summary>
        [NotMapped]
        public decimal WZ2DCZYCB
        {
            get
            {
                if (WZ2YDFY == 0) return 0;
                return WZ2ZYZS / WZ2YDFY;
            }
        }

        /// <summary>
        /// 网站1集客进度
        /// </summary>
        [NotMapped]
        public decimal WZ1JKJD
        {
            get
            {
                var d = WLJKMB * WZ1FYZB / 100;
                if (d == 0) return 0;
                return WZ1ZYZS * 100 / d;
            }
        }
        /// <summary>
        /// 网站1集客进度差
        /// </summary>
        [NotMapped]
        public decimal WZ1JKJDDiff
        {
            get
            {
                return 100 - WZ1JKJD;
            }
        }
        /// <summary>
        /// 网站2集客进度
        /// </summary>
        [NotMapped]
        public decimal WZ2JKJD
        {
            get
            {
                var d = WLJKMB * WZ2FYZB / 100;
                if (d == 0) return 0;
                return WZ2ZYZS * 100 / d;
            }
        }
        /// <summary>
        /// 网站2集客进度差
        /// </summary>
        [NotMapped]
        public decimal WZ2JKJDDiff
        {
            get
            {
                return 100 - WZ2JKJD;
            }
        }
        /// <summary>
        /// 网站1发帖率
        /// </summary>
        [NotMapped]
        public decimal WZ1FDLV
        {
            get
            {
                if (WZ1JHFTS == 0) return 0;
                return WZ1SJFTS * 100 / WZ1JHFTS;
            }
        }
        /// <summary>
        /// 网站2发帖率
        /// </summary>
        [NotMapped]
        public decimal WZ2FDLV
        {
            get
            {
                if (WZ2JHFTS == 0) return 0;
                return WZ2SJFTS * 100 / WZ2JHFTS;
            }
        }
    }
}
